/*************************************************
Author: byron
Date: 05/07/2013
Description:
Notes: 
*************************************************/

#ifndef __CAcademyBossData_h__
#define __CAcademyBossData_h__

#include "commclass.h"
#include "CActCfg.h"
#include "../common/CRankArray.h"
#include "../common/CRandArray.h"
#include "MsgAcademyBoss.pb.h"

class MsgAcademyBossAtkRank;

class CAcademyBossRole
{
public:
    CAcademyBossRole()
    {
        Clear();
    }

    void Clear()
    {
        _chDieTimes = 0;
        _chMerlinTimes = 0;
        _iEndTime = 0;
        _iBeginTime = 0;
        _iAtkValue = 0;
    }

    virtual ~CAcademyBossRole()
    {
    }

    char GetDieTimes() const {return _chDieTimes;}
    char GetMerlinTimes() const {return _chMerlinTimes;}
    int GetAtkValue() const {return _iAtkValue;}
    int GetEndTime() const {return _iEndTime;}
    int GetBeginTime() const {return _iBeginTime;}

    void SetDieTimes(char chDieTimes){_chDieTimes = chDieTimes;}
    void SetMerlinTimes(char chMerlinTimes){_chMerlinTimes = chMerlinTimes;}
    void SetAtkValue(int iNewAtk){_iAtkValue = iNewAtk;}
    void SetEndTime(int iEndTime){_iEndTime = iEndTime;}
    void SetBeginTime(int iBeginTime){_iBeginTime = iBeginTime;}

    void AddAtkValue(int iChgAtk)
    {
        _iAtkValue = CT_MAX(_iAtkValue + iChgAtk, 0);
    }

private:
    char        _chDieTimes;    //死亡次数
    char        _chMerlinTimes; //梅林祝福购买次数
    int         _iEndTime;      //失效时刻
    int         _iBeginTime;    //开启时刻
    int         _iAtkValue;     //攻击怪物伤害总量
};

class CAcademyBossRoleList
{
public:
    CAcademyBossRoleList()
    {
        Clear();
    }

    void Clear()
    {
        _astRoles.m_iUsedCount = _astRoles.GetCount();
        for (int i = 0; i < _astRoles.Size(); ++i)
        {
            _astRoles[i].Clear();
        }
    }

    virtual ~CAcademyBossRoleList()
    {
    }

    int FindAcademyRole(int iAcademyType);

    CAcademyBossRole& GetAcademyRole(int iIndex);

private:
    CTLib::CTArray<CAcademyBossRole, ACADEMY_TYPE_COUNT> _astRoles;
};

class CAcademyBossAtkUnit
{
public:
    CAcademyBossAtkUnit()
    {
        Clear();
    }

    void Clear()
    {
        _uiGID = 0;
        _iAcademy = 0;
        _iAtkValue = 0;
        _sRoleName.Set("");
    }

    virtual ~CAcademyBossAtkUnit()
    {
    }

    int GetAcademy() const {return _iAcademy;}
    int GetAtkValue() const {return _iAtkValue;}
    unsigned int GetGID() const {return _uiGID;}
    char* GetRoleName() const {return _sRoleName.Get();}

    void SetAcademy(int iAcademy){_iAcademy = iAcademy;}
    void SetAtkValue(int iAtkValue){_iAtkValue = iAtkValue;}
    void SetGID(unsigned int uiGID){_uiGID = uiGID;}
    void SetRoleName(const char* pszName){_sRoleName.Set(pszName);}
    void GetAtkRankUnit(MsgAcademyBossAtkRank& stAtkRankUnit);

private:
    int                 _iAcademy;
    int                 _iAtkValue;     //攻击伤害
    unsigned int        _uiGID;         //角色GID
    CTSizeString<ROLENAME_LEN>  _sRoleName; //角色名
};

class CAcademyBossMonster
{
public:
    enum ACADEMY_BOSS_MONSTER_TAG
    {
        AB_MONSTER_ATK_RANK_COUNT = 100,   //怪物受击伤害榜单元上限
        AB_MONSTER_RANK_SHOW_COUNT = 10,   //受击伤害榜前端显示数量
    };

    CAcademyBossMonster()
    {
        Clear();
    }

    void Clear()
    {
        _iEndTime = 0;
        _iAtkValue = 0;
        _iLeftMonHP = 0;
        _iRightMonHP = 0;
        _iBossMonHP = 0;
        _iLeftMonHPMax = 0;
        _iRightMonHPMax = 0;
        _iBossMonHPMax = 0;
        _iLastNotify = 0;
        _iWorldLevel = 0;
        _iMonBornTime = 0;
        _iBossBornTime = 0;
        _uiLeftMonGroupID = 0;
        _uiRightMonGroupID = 0;
        _uiBossMonGroupID = 0;

        _uiLeftMonsterID = 0;
        _uiRightMonsterID = 0;
        _uiBossMonsterID = 0;

        _uiLastNotifyGID = 0;

        _stMsgLeftRole.Clear();
        _stMsgRightRole.Clear();
        _stMsgBossRole.Clear();

        _stLeftRoleEquip.Clear();
        _stRightRoleEquip.Clear();
        _stBossRoleEquip.Clear();

        _stAtkRank.Clear();
    }

    virtual ~CAcademyBossMonster()
    {
    }

    int GetEndTime() const {return _iEndTime;}
    int GetAtkValue() const {return _iAtkValue;}
    int GetLeftMonHP() const {return _iLeftMonHP;}
    int GetRightMonHP() const {return _iRightMonHP;}
    int GetBossMonHP() const {return _iBossMonHP;}
    int GetLeftMonHPMax() const {return _iLeftMonHPMax;}
    int GetRightMonHPMax() const {return _iRightMonHPMax;}
    int GetBossMonHPMax() const {return _iBossMonHPMax;}
    int GetLastNotify() const {return _iLastNotify;}
    int GetWorldLevel() const {return _iWorldLevel;}
    int GetMonBornTime() const {return _iMonBornTime;}
    int GetBossBornTime() const {return _iBossBornTime;}
    unsigned int GetLastNotifyGID() const {return _uiLastNotifyGID;}
    unsigned int GetLeftMonGroupID() const {return _uiLeftMonGroupID;}
    unsigned int GetRightMonGroupID() const {return _uiRightMonGroupID;}
    unsigned int GetBossMonGroupID() const {return _uiBossMonGroupID;}

    unsigned int GetLeftMonsterID() const {return _uiLeftMonsterID;}
    unsigned int GetRightMonsterID() const {return _uiRightMonsterID;}
    unsigned int GetBossMonsterID() const {return _uiBossMonsterID;}

    MsgAcademyBossMonster& GetMsgLeftRole() {return _stMsgLeftRole;}
    MsgAcademyBossMonster& GetMsgRightRole() {return _stMsgRightRole;}
    MsgAcademyBossMonster& GetMsgBossRole() {return _stMsgBossRole;}

	CPlayerEquip& GetLeftRoleEquip() {return _stLeftRoleEquip;}  
	CPlayerEquip& GetRightRoleEquip() {return _stRightRoleEquip;}  
	CPlayerEquip& GetBossRoleEquip() {return _stBossRoleEquip;}  

    void SetEndTime(int iEndTime){_iEndTime = iEndTime;}
    void SetAtkValue(int iAtkValue){_iAtkValue = iAtkValue;}
    void SetLeftMonHP(int iMonsterHP){_iLeftMonHP = iMonsterHP;}
    void SetLeftMonHPMax(int iMonsterHPMax){_iLeftMonHPMax = iMonsterHPMax;}
    void SetRightMonHP(int iMonsterHP){_iRightMonHP = iMonsterHP;}
    void SetRightMonHPMax(int iMonsterHPMax){_iRightMonHPMax = iMonsterHPMax;}
    void SetBossMonHP(int iMonsterHP){_iBossMonHP = iMonsterHP;}
    void SetBossMonHPMax(int iMonsterHPMax){_iBossMonHPMax = iMonsterHPMax;}
    void SetLastNotify(int iLastNotify){_iLastNotify = iLastNotify;}
    void SetWorldLevel(int iWorldLevel){_iWorldLevel = iWorldLevel;}
    void SetMonBornTime(int iBornTime){_iMonBornTime = iBornTime;}
    void SetBossBornTime(int iBornTime){_iBossBornTime = iBornTime;}
    void SetLastNotifyGID(unsigned int uiGID) {_uiLastNotifyGID = uiGID;}

    void SetLeftMonGroupID(unsigned int uiID) {_uiLeftMonGroupID = uiID;}
    void SetRightMonGroupID(unsigned int uiID) {_uiRightMonGroupID = uiID;}
    void SetBossMonGroupID(unsigned int uiID) {_uiBossMonGroupID = uiID;}

    void SetLeftMonsterID(unsigned int uiID) {_uiLeftMonsterID = uiID;}
    void SetRightMonsterID(unsigned int uiID) {_uiRightMonsterID = uiID;}
    void SetBossMonsterID(unsigned int uiID) {_uiBossMonsterID = uiID;}

    void AddAtkValue(int iChgAtk)
    {
        _iAtkValue = CT_MAX(_iAtkValue + iChgAtk, 0);
    }

    int UpdateRank(CAcademyBossAtkUnit& stNewUnit, int& iOld, int& iNew)
    {
        return _stAtkRank.Update(stNewUnit, iOld, iNew);
    }

    int GetRankSize() const {return _stAtkRank.Size();}

    CAcademyBossAtkUnit& GetRankUnit(int iIndex)
    {
        return _stAtkRank[iIndex];
    }

    int GetRankRoleOrder(unsigned int uiGID);

private:
    int             _iEndTime;
    int             _iAtkValue;

    int             _iLeftMonHP;
    int             _iRightMonHP;
    int             _iBossMonHP;

    int             _iLeftMonHPMax;
    int             _iRightMonHPMax;
    int             _iBossMonHPMax;

    int             _iLastNotify;
    int             _iWorldLevel;
    int             _iMonBornTime;
    int             _iBossBornTime;

    unsigned int    _uiLeftMonGroupID;
    unsigned int    _uiRightMonGroupID;
    unsigned int    _uiBossMonGroupID;

    unsigned int    _uiLeftMonsterID;
    unsigned int    _uiRightMonsterID;
    unsigned int    _uiBossMonsterID;

    unsigned int    _uiLastNotifyGID;

    MsgAcademyBossMonster _stMsgLeftRole;
    MsgAcademyBossMonster _stMsgRightRole;
    MsgAcademyBossMonster _stMsgBossRole;

	CPlayerEquip        _stLeftRoleEquip;
	CPlayerEquip        _stRightRoleEquip;
	CPlayerEquip        _stBossRoleEquip;

    CRankArray<CAcademyBossAtkUnit, AB_MONSTER_ATK_RANK_COUNT> _stAtkRank;
};

class CAcademyBossMonList
{
public:
    CAcademyBossMonList()
    {
        Clear();
    }

    void Clear()
    {
        _astMonsters.m_iUsedCount = _astMonsters.GetCount();
        for (int i = 0; i < _astMonsters.Size(); ++i)
        {
            _astMonsters[i].Clear();
        }
    }

    virtual ~CAcademyBossMonList()
    {
    }

    int FindAcademyMon(int iAcademyType);

    int GetAcademyMonSize() const
    {
        return _astMonsters.Size();
    }

    CAcademyBossMonster& GetAcademyMon(int iIndex);

private:
    CTLib::CTArray<CAcademyBossMonster, ACADEMY_TYPE_COUNT> _astMonsters;
};

class CAcademyBossRandom
{
public:
    CAcademyBossRandom()
    {
        Clear();
    }

    void Clear()
    {
        _iLastRandTime = 0;
        _aiAcademyRand.m_iUsedCount = _aiAcademyRand.GetCount();
        _aiAcademyRand[0] = ACADEMY_TYPE_GRAN;
        _aiAcademyRand[1] = ACADEMY_TYPE_SLEN;
        //_aiAcademyRand[2] = ACADEMY_TYPE_RAVAN;
        //_aiAcademyRand[3] = ACADEMY_TYPE_HUFF;
        //这里使用下标很不灵活
    }

    virtual ~CAcademyBossRandom()
    {
    }

    void AcademyRandom();

    int GetLastRandTime() const {return _iLastRandTime;}
    void SetLastRandTime(int iTime){_iLastRandTime = iTime;}

    int FindAcademyRand(int iAcademyType);

    int GetAcademyRand(int iIndex);

private:
    int _iLastRandTime;
    CRandArray<int, ACADEMY_TYPE_COUNT_CURRENT> _aiAcademyRand;
};

class CAcademyBossUnit
{
public:
    CAcademyBossUnit()
    {
        Clear();
    }

    void Clear()
    {
        _shActID = 0;
        _uiMapID = 0;
    }

    virtual ~CAcademyBossUnit()
    {
    }

    short GetActID() const {return _shActID;}
    unsigned int GetMapID() const {return _uiMapID;}

    void SetActID(short shActID) {_shActID = shActID;}
    void SetMapID(unsigned int uiMapID) {_uiMapID = uiMapID;}

private:
    short           _shActID;
    unsigned int    _uiMapID;
};

class CAcademyBossAct
{
public:
    CAcademyBossAct()
    {
        Clear();
    }

    void Clear()
    {
        _astActInfo.m_iUsedCount = _astActInfo.GetCount();
        _astActInfo[0].SetActID(ACT_ID_GRAN_BOSS);
        _astActInfo[1].SetActID(ACT_ID_SLEN_BOSS);
        //_astActInfo[2].SetActID(ACT_ID_RAVAN_BOSS);
        //_astActInfo[3].SetActID(ACT_ID_HUFF_BOSS);
        _astActInfo[0].SetMapID(0);
        _astActInfo[1].SetMapID(0);
        //_astActInfo[2].SetMapID(0);
        //_astActInfo[3].SetMapID(0);
        //这里使用下标很不灵活
    }

    virtual ~CAcademyBossAct()
    {
    }

    int FindAcademyAct(int iAcademyType);

    CAcademyBossUnit& GetAcademyAct(int iIndex);

private:
    CTLib::CTArray<CAcademyBossUnit, ACADEMY_TYPE_COUNT_CURRENT> _astActInfo;
};

#endif //__CAcademyBossData_h__

